

<%@page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>

<%@taglib prefix="jstl" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@taglib prefix="security"
	uri="http://www.springframework.org/security/tags"%>
<%@taglib prefix="display" uri="http://displaytag.sf.net"%>
<%@taglib prefix="acme" tagdir="/WEB-INF/tags"%>

<form:form action="${requestURI}" modelAttribute="projectForm">

	<form:hidden path="id" />

	<jstl:if test="${editable}">
		<form:hidden path="creator" />
		<acme:textbox code="project.referenceNumber" path="referenceNumber"
			readonly="true" />
		<acme:textbox code="project.creationMoment" path="creationMoment"
			readonly="true" />

		<acme:textbox code="project.title" path="title" />
		<acme:textarea code="project.description" path="description" />
		<acme:textarea code="project.goal" path="goal" />

		<acme:textbox code="project.startMoment" path="startMoment" />
		<acme:textbox code="project.endMoment" path="endMoment" />

		<jstl:if test="${isNew }">
			<form:hidden path="totalAmountOfWork" />
			<form:hidden path="status" />
		</jstl:if>
		<jstl:if test="${!isNew}">
			<acme:textbox code="project.totalAmountOfWork"
				path="totalAmountOfWork" readonly="true" />
			<acme:textbox code="project.status" path="status" readonly="true" />
		</jstl:if>

	</jstl:if>

	<jstl:if test="${!editable}">
		<acme:textbox code="project.creator" path="creator.name"
			readonly="true" />
		<acme:textbox code="project.referenceNumber" path="referenceNumber"
			readonly="true" />
		<acme:textbox code="project.creationMoment" path="creationMoment"
			readonly="true" />

		<acme:textbox code="project.title" path="title" readonly="true" />
		<acme:textarea code="project.description" path="description"
			readonly="true" />
		<acme:textarea code="project.goal" path="goal" readonly="true" />

		<acme:textbox code="project.startMoment" path="startMoment"
			readonly="true" />
		<acme:textbox code="project.endMoment" path="endMoment"
			readonly="true" />

		<jstl:if test="${!isNew}">
			<acme:textbox code="project.totalAmountOfWork"
				path="totalAmountOfWork" readonly="true" />
			<acme:textbox code="project.status" path="status" readonly="true" />
		</jstl:if>
	</jstl:if>
	
	<jstl:if test="${(started || finished) && (isOwner || joined || following) }">
	<h1><spring:message code = "project.participants" /></h1>
	<display:table pagesize="5" class="displaytag" keepStatus="true"
	name="registrations" requestURI="${requestURI}" id="row">

	<spring:message code="project.registration.user"
		var="registrationUserHeader" />
	<display:column property="user.name"
		title="${registrationUserHeader}" />

	<spring:message code="project.registration.amountOfWork" 
		var="registrationAmountHeader" />
	<display:column property="totalAmountOfWork"
		title="${registrationAmountHeader}"/>

	</display:table>
	</jstl:if>
	
	<jstl:if test="${(started || finished) && (isOwner || joined || following) }">
	<h1><spring:message code = "project.stream" /></h1>
	<display:table pagesize="5" class="displaytag" keepStatus="true"
	name="workUpdates" requestURI="${requestURI}" id="row">

	<spring:message code="project.workUpdate.description"
		var="workUpdateDescriptionHeader" />
	<display:column property="description"
		title="${workUpdateDescriptionHeader}" />

	<spring:message code="project.workUpdate.updateMoment" 
		var="workUpdateUpdateMomentHeader" />
	<display:column property="updateMoment"
		title="${workUpdateUpdateMomentHeader}" format="{0,date,dd/MM/yyyy HH:mm}"/>

	<spring:message code="project.workUpdate.amountOfWork"
		var="workUpdateAmountOfWorkHeader" />
	<display:column property="amountOfWork"
		title="${workUpdateAmountOfWorkHeader}"  />
		
	<spring:message code="project.workUpdate.participant"
		var="workUpdateAmountOfWorkHeader" />
	<display:column property="registration.user.name"
		title="${workUpdateAmountOfWorkHeader}"  />

	</display:table>
	</jstl:if>
	<!-- -----------------USER-------------------------------------- -->
	<security:authorize access="hasRole('USER')">

		<jstl:if test="${isNew}">
			<acme:submit code="project.create" name="save" />
		</jstl:if>

		<jstl:if test="${!isNew && creating}">

			<acme:cancel code="project.viewVacancies"
				url="/vacancy/user/list.do?projectId=${projectId}" />
			<jstl:if test="${hasVacancies}">
				<acme:cancel code="project.finishCreate"
					url="/project/user/finishCreate.do?projectId=${projectId}" />
			</jstl:if>
		</jstl:if>
		<!-- RECRUITING--------------------------------------------------- -->
		<jstl:if test="${recruiting}">
			<acme:cancel code="project.viewVacancies"
				url="/vacancy/user/list.do?projectId=${projectId}" />

			<jstl:if test="${canJoin && !joined}">
				<acme:cancel code="project.join" url="/registration/user/create.do?projectId=${projectId }" />
			</jstl:if>
		</jstl:if>
		<!-- STARTED------------------------------------------------------ -->
		<jstl:if test="${isOwner && started}">
			<acme:cancel code="project.finishProject"
				url="/project/user/finishProject.do?projectId=${projectId}" />
		</jstl:if>

		<jstl:if test="${!isOwner && started && !joined && !following}">
			<acme:cancel code="project.followProject"
				url="/project/user/followProject.do?projectId=${projectId}" />
		</jstl:if>

		<jstl:if test="${!isOwner && started && following}">
			<acme:cancel code="project.unFollowProject"
				url="/project/user/unfollowProject.do?projectId=${projectId}" />
		</jstl:if>
		
		<jstl:if test="${joined && started}">
			<acme:cancel code="project.makeWorkUpdate"
				url="/workUpdate/user/create.do?projectId=${projectId}" />
		</jstl:if>

		<!-- FINISHED---------------------------------------- -->

		<acme:cancel code="project.cancel" url="/welcome/index.do" />

	</security:authorize>
	<!-- -----------------ANONYMOUS-------------------------------------- -->
	<security:authorize access="isAnonymous()">
		<acme:cancel code="project.goBack" url="/welcome/index.do" />
	</security:authorize>

</form:form>



